package com.duniptech.soa.service;

import javax.activation.DataHandler;

import org.apache.axiom.attachments.ByteArrayDataSource;

import com.duniptech.soa.stub.compile.CompileStub;


public class CompileService implements CompileServiceInterface {
	protected CompileStub service;
		
	public CompileService(String endPoint) throws Exception {
		service = new CompileStub(endPoint);
	}
	
	public String compile(String serverPackage, byte[] arrayOfFileNames) throws Exception {
		CompileStub.Compile compileArgs = new CompileStub.Compile();
		// 1.- Package name
		compileArgs.setServerPackage(serverPackage);
		// 2.- File names
		ByteArrayDataSource ds1 = new ByteArrayDataSource(arrayOfFileNames); 
		DataHandler dh1 = new DataHandler(ds1);
		compileArgs.setArrayOfFileNames(dh1);
		// RUN
		CompileStub.CompileResponse response = service.compile(compileArgs);
		return response.get_return();
	}
}
